<?php
/**
 * Created by PhpStorm.
 * User: td
 * Date: 15/2/1
 * Time: 下午10:34
 */

namespace Home\Model;
use Think\Model;

class ExperienceModel extends Model {

    protected $tableName = 'Experience';
    protected $pk        = 'exp_id';

    //返回项目经历信息
    public function getExperienceInfo($exp_id){
        $experience_field = array('exp_id','resume_id','project_name','role','description','url');
        $experience_map['exp_id'] = array('eq',$exp_id);
        $experience_result = $this->field($experience_field)->where($experience_map)->select();
        if(is_array($experience_result)){
            foreach($experience_result as &$experience_result_one){
                $attachment_map['exp_id'] = array('eq',$experience_result_one['exp_id']);
                $attachment_db = M('Attachment');
                $attachment_result = $attachment_db->where($attachment_map)->select();
                if(is_array($attachment_result)){
                    $experience_result_one['attachment'] = $attachment_result;
                }else{
                    //获取attachment表失败
                }
            }
            return $experience_result[0];
        }else{
            return false;
        }
    }

} 